package sf.model.fields;

import java.awt.event.FocusListener;
import java.math.BigDecimal;
import java.sql.Timestamp;

import javax.swing.JComponent;

public class FieldFactory {

	private FieldFactory() {}

	public static JComponent getFieldForClass(Class<?> cls, String naziv, int columnSize, FocusListener fl) {
		JComponent field = null;

		if (cls.equals(Long.class) || cls.equals(Integer.class)) {
			field = new NumberField(naziv, columnSize);
			field.addFocusListener(fl);
		}
		else if (cls.equals(BigDecimal.class)) {
			field = new DecimalField(naziv, columnSize);
			field.addFocusListener(fl);
		}
		else if (cls.equals(Timestamp.class)) {
			field = new DateField(naziv, columnSize);
			field.addFocusListener(fl);
		}
		else if (cls.equals(Boolean.class)) {
			field = new BoolFieldNew(naziv);
		}
		else if (cls.equals(byte[].class)) {
			field = new ImageField(naziv);
		}
		else {
			field = new StringField(naziv, columnSize);
			field.addFocusListener(fl);
		}

		return field;
	}
}